import userApi from '@/api/declaration/userApi'
import httpRequest from '@/config/axios/httpRequest'
import {
  CreateUserReq,
  CreateUserResp,
  DeleteUserReq,
  DeleteUserResp,
  ExportUserReq,
  QueryUserDetailReq,
  QueryUserPageReq,
  QueryUserPageResp,
  UpdateUserReq,
  UpdateUserResp,
  UserInfoModel
} from '@/models/system/UserModel'

// 查询用户管理列表
export const getUserPage = async (params: QueryUserPageReq) => {
  return await httpRequest.get<QueryUserPageResp>(userApi.QueryUserPage, { params })
}

// 查询用户详情
export const getUser = async (params: QueryUserDetailReq) => {
  return await httpRequest.get<UserInfoModel>(userApi.QueryUserDetail, { params })
}

// 新增用户
export const createUser = async (data: CreateUserReq) => {
  return await httpRequest.post<CreateUserResp>(userApi.CreateUser, data)
}

// 修改用户
export const updateUser = async (data: UpdateUserReq) => {
  return await httpRequest.put<UpdateUserResp>(userApi.UpdateUser, data)
}

// 删除用户
export const deleteUser = async (params: DeleteUserReq) => {
  return await httpRequest.delete<DeleteUserResp>(userApi.DeleteUser, { params })
}

// 导出用户
export const exportUser = async (params: ExportUserReq) => {
  return await httpRequest.download(userApi.ExportUser, { params, responseType: 'blob' })
}

// 下载用户导入模板
export const importUserTemplate = async () => {
  return await httpRequest.download(userApi.ImportUserTemplate, { responseType: 'blob' })
}

// 用户密码重置
export const resetUserPwd = async (id: number, password: string) => {
  return await httpRequest.put(userApi.ResetUserPwd, { ID: id, Password: password })
}

// 用户状态修改
export const updateUserStatus = async (id: number, status: number) => {
  return await httpRequest.put(userApi.UpdateUserStatus, { ID: id, Status: status })
}


export const GetSimpleUserList = async () => {
  return await httpRequest.get(userApi.GetSimpleUserList)
}